package com.hxkj.cst.chengshuitong.presenter

import android.content.Context
import com.google.gson.Gson
import com.hxkj.cst.chengshuitong.AreaBean
import com.hxkj.cst.chengshuitong.control.FirstRatePaymentControl

/**
 * 作者：LuoYang
 * 时间：2017/6/1:13:22
 * 邮箱：18981443691@163.com
 * 说明：
 */
class FirstRatePaymentPresenter(val view: FirstRatePaymentControl.View,
                                val context: Context) : FirstRatePaymentControl.Presenter {

    val areaDataSource = "{XZQHLB:{xzqh:[ {XZQHDM:120000,XZQHMC:天津市,XSXZQH:[]}, {XZQHDM:330000,XZQHMC:浙江省,XSXZQH:[ {XZQHDM:330100,XZQHMC:杭州市,XSXZQH:[]}, {XZQHDM:330200,XZQHMC:宁波市,XSXZQH:[]}, {XZQHDM:330300,XZQHMC:温州市,XSXZQH:[]}, {XZQHDM:330400,XZQHMC:嘉兴市,XSXZQH:[]}, {XZQHDM:330500,XZQHMC:湖州市,XSXZQH:[]}, {XZQHDM:330600,XZQHMC:绍兴市,XSXZQH:[]},{XZQHDM:330700,XZQHMC:金华市,XSXZQH:[]}, {XZQHDM:330800,XZQHMC:衢州市,XSXZQH:[]},{XZQHDM:330900,XZQHMC:舟山市,XSXZQH:[]}, {XZQHDM:331000,XZQHMC:台州市,XSXZQH:[]},{XZQHDM:331100,XZQHMC:丽水市,XSXZQH:[]}]}, {XZQHDM:510000,XZQHMC:四川省,XSXZQH:[ {XZQHDM:510100,XZQHMC:成都市,XSXZQH:[]},{XZQHDM:510300,XZQHMC:自贡市,XSXZQH:[]}, {XZQHDM:510400,XZQHMC:攀枝花市,XSXZQH:[]}, {XZQHDM:510500,XZQHMC:泸州市,XSXZQH:[]}, {XZQHDM:510600,XZQHMC:德阳市,XSXZQH:[]}, {XZQHDM:510700,XZQHMC:绵阳市,XSXZQH:[]}, {XZQHDM:510800,XZQHMC:广元市,XSXZQH:[]}, {XZQHDM:510900,XZQHMC:遂宁市,XSXZQH:[]}, {XZQHDM:511000,XZQHMC:内江市,XSXZQH:[]}, {XZQHDM:511100,XZQHMC:乐山市,XSXZQH:[]}, {XZQHDM:511300,XZQHMC:南充市,XSXZQH:[]}, {XZQHDM:511400,XZQHMC:眉山市,XSXZQH:[]}, {XZQHDM:511500,XZQHMC:宜宾市,XSXZQH:[]},{XZQHDM:511600,XZQHMC:广安市,XSXZQH:[]}, {XZQHDM:511700,XZQHMC:达州市,XSXZQH:[]},{XZQHDM:511800,XZQHMC:雅安市,XSXZQH:[]}, {XZQHDM:511900,XZQHMC:巴中市,XSXZQH:[]},{XZQHDM:512000,XZQHMC:资阳市,XSXZQH:[]}, {XZQHDM:513200,XZQHMC:阿坝藏族羌族自治州,XSXZQH:[]}, {XZQHDM:513300,XZQHMC:甘孜藏族自治州,XSXZQH:[]}, {XZQHDM:513400,XZQHMC:凉山彝族自治州,XSXZQH:[]}]}],version:1}}"


    override fun loadAreaDataSource() {

        val areaBean = Gson().fromJson(areaDataSource, AreaBean::class.java)
        val areaList = areaBean.XZQHLB.xzqh
        var defaultIndex = 0

        if (areaList.isNotEmpty()) {
            for (index in 0 until areaList.size) {
                val provinceName = areaList[index].XZQHMC
                if (provinceName != "北京市"
                        && provinceName != "重庆市"
                        && provinceName != "上海市"
                        && provinceName != "天津市"
                        && provinceName != "成都市") {
                    defaultIndex = index
                    break
                }
            }
            view.setUpWheelView(areaList, defaultIndex)
        }
    }

}